<%@ page import="java.net.URLDecoder" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%
    Cookie[] cookies = request.getCookies();
    String username="";
%>

<html>
<head>
    <title>书籍列表</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 引入 Bootstrap -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css"rel="stylesheet">
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/bootstrap.min.js"></script>
   <%-- <style>
        body{
            width: 100%;
        }


        .sb{
            position: absolute;
            left: 50%;
            transform: translate(-50%,-50%);
        }
        img{
            width: 190px;
            height: 240px;
        }

        td{
            line-height: 240px;
        }

        .dropdown-toggle{
            border: none;
            font-size: 16px;
            font-weight: bold;
            margin-bottom: -6px;
            margin-left: -14px;
            background-color: #28FF28;
        }
        #sbbbb{
            position: sticky;
            top: 0;
            background-color: #28FF28;
        }

    </style>--%>


</head>
<body>
​
<%--<div class="container">
    ​
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="page-header">
                <h1>
                    <small>书籍列表 —— 显示所有书籍</small>
                </h1>
                <form action="${pageContext.request.contextPath}/book/queryBookByName" method="get">
                    <input type="text" name="name" id="name" placeholder="请输入要查询的书籍" value="${key}"/>
                    <input type="submit" id="btn04">
                </form>
                <h5>欢迎${sessionScope.user.userName}，<c:choose><c:when test="${user.type==1}">普通用户</c:when><c:otherwise>管理员</c:otherwise></c:choose></h5>
                <h5><a href="${pageContext.request.contextPath}/bookStore/index">进入商城</a></h5>
            </div>


        </div>
    </div>
    ​
    <div class="row">
        <div class="col-md-4 column">
            <a class="btn btn-primary"href="${pageContext.request.contextPath}/book/toAddBook">新增</a>
        </div>
    </div>
    ​
    <div class="row clearfix">
        <div class="col-md-12 column">
            <table class="table table-hover table-striped">
                <thead id="sbbbb">
                <tr>
                    <th>书籍封面</th>
                    <th>书籍名字</th>
                    <th class="dsb">
                        <div class="dropdown">
                            <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                                书籍类型
                                <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                                <li><a href="${pageContext.request.contextPath}/book/allBook">全部</a></li>
                                <c:forEach items="${bookKind}" var="bookKind">
                                    <li><a href="${pageContext.request.contextPath}/book/queryBookByKindId?bookkindId=${bookKind.kindId}">${bookKind.kindName}</a></li>
                                </c:forEach>
                            </ul>
                        </div>
                    </th>
                    <th>书籍数量</th>
                    <th>书籍价格</th>
                    <th>书籍详情</th>
                    <th>操作</th>
                </tr>
                </thead>
                ​
                <tbody>
                <c:forEach var="book" items="${pageInfo.list}">
                    <tr>
                        <td><img src="${book.bookImg}" alt="${book.bookName}"></td>
                        <td>${book.bookName}</td>
                        <td>${book.bookKind.kindName}</td>
                        <td>${book.bookCounts}</td>
                        <td>${book.price}</td>
                        <td>${book.detail}</td>
                        <td>
                            <a href="${pageContext.request.contextPath}/book/toUpdateBook?id=${book.bookId}">更改</a> |
                            <a href="${pageContext.request.contextPath}/book/deletePaper?id=${book.bookId}">删除</a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>

            </table>
        </div>
    </div>
</div>

<div class="sb">
    <nav aria-label="Page navigation">
    <ul class="pagination col-md-12 col-lg-12 column">
        <li>
            <a href="${requestScope['javax.servlet.forward.request_uri']}?name=<%=request.getAttribute("key")%>&pn=${pageInfo.pageNum-1}" id="btn02" aria-label="Previous">
                <span aria-hidden="true">&laquo;</span>
            </a>
        </li>
            <c:forEach begin="1" end="${pageInfo.pages}" var="i">
                <li><a href="${requestScope['javax.servlet.forward.request_uri']}?name=<%=request.getAttribute("key")%>&pn=${i}">${i}</a></li>
            </c:forEach>
        <li>
            <a href="${requestScope['javax.servlet.forward.request_uri']}?name=<%=request.getAttribute("key")%>&pn=${pageInfo.pageNum+1}" id="btn01" aria-label="Next">
                <span aria-hidden="true">&raquo;</span>
            </a>
        </li>
    </ul>
</nav>
</div>
<p id="ssr"></p>--%>
<jsp:include page="header.jsp"/>
<section class="rt_wrap content mCustomScrollbar">
    <div class="rt_content">
        <div class="page_title">
            <h2 class="fl">商品列表</h2>
            <a href="${pageContext.request.contextPath}/book/toAddBook" class="fr top_rt_btn add_icon">添加商品</a>
        </div>
        <section class="mtb">
            <select class="select">
                <option>下拉菜单</option>
                <option>菜单1</option>
            </select>
            <form action="${pageContext.request.contextPath}/book/queryBookByName" method="post">
                <input type="text" class="textbox textbox_225" placeholder="输入产品关键词或产品货号..." name="name"/>
                <input type="submit" value="查询" class="group_btn"/>
            </form>
        </section>
        <table class="table">
            <tr>
                <th>缩略图</th>
                <th>产品名称</th>
                <th>商品Id</th>
                <th>单价</th>
                <th>分类</th>
                <th>作者</th>
                <th>详细信息</th>
                <th>展示</th>
                <th>库存</th>
                <th>操作</th>
            </tr>
            <c:forEach var="book" items="${pageInfo.list}">
                <tr>
                    <td class="center"><img src="${book.bookImg}" width="50" height="50"/></td>
                    <td>${book.bookName}</td>
                    <td class="center">${book.bookId}</td>
                    <td class="center"><strong class="rmb_icon">${book.price}.00</strong></td>
                    <td class="center">${book.bookKind.kindName}</td>
                    <td class="center">${book.author.authorName}</td>
                    <td class="center" style="display:inline-block;width:145px;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;height: 70px;">${book.detail}</td>
                    <td class="center">
                        <c:if test="${book.type == 0}">不推荐</c:if>
                        <c:if test="${book.type == 1}">热门推荐</c:if>
                        <c:if test="${book.type == 3}">每周热门</c:if>
                    </td>
                    <td class="center">${book.bookCounts}</td>
                    <td class="center">
                        <a href="http://www.mycodes.net" title="预览" class="link_icon" target="_blank">&#118;</a>
                        <a href="${pageContext.request.contextPath}/book/toUpdateBook?id=${book.bookId}" title="编辑" class="link_icon">&#101;</a>
                        <a href="${pageContext.request.contextPath}/book/deletePaper?id=${book.bookId}&pn=${pageInfo.pageNum}" title="删除" class="link_icon">&#100;</a>
                    </td>
                </tr>
            </c:forEach>
        </table>
        <aside class="paging">
            <a href="${requestScope['javax.servlet.forward.request_uri']}?name=<%=request.getAttribute("key")%>&pn=${pageInfo.pageNum-1}" id="btn02">上一页</a>
            <c:forEach begin="1" end="${pageInfo.pages}" var="i">
                <a href="${requestScope['javax.servlet.forward.request_uri']}?name=<%=request.getAttribute("key")%>&pn=${i}">${i}</a>
            </c:forEach>
            <a href="${requestScope['javax.servlet.forward.request_uri']}?name=<%=request.getAttribute("key")%>&pn=${pageInfo.pageNum+1}" id="btn01">下一页</a>
        </aside>
    </div>
</section>

<p id="ssr"></p>

</body>
</html>